<template>
  <el-select style="width: 100%;" v-bind="{ ...attr }" :model-value="props.modelValue" @change="changeHandler">
    <el-option label="全部" value="" />
    <el-option v-for="(item, index) in filterState" :key="index" :label="item.label" :value="item.value" />
  </el-select>
</template>

<script>
export default {
  inheritAttrs: false
}
</script>

<script setup>
import { ElSelect, ElOption } from 'element-plus'
import globalData from '@/staticData/globalData'
import { deepClone } from '@/util'

const props = defineProps({
  modelValue: [String, Number],
  attr: {
    type: Object,
    default: () => {
      return { placeholder: '请选择' }
    }
  },
  formItem: {
    type: Object
  }
})
const emit = defineEmits(['update:modelValue'])
const filterState = computed(() => {
  if (!props.attr.noEnd) {
    return globalData.CLASS_STATE_LIST
  } else {
    const temp = deepClone(globalData.CLASS_STATE_LIST)
    temp.splice(2, 1)
    return temp
  }
})

const changeHandler = e => {
  emit('update:modelValue', e)
}

</script>
